
function initParm() {
    outMessage("");
    var pageSum = 0;
    var readPageAmount = document.getElementById('sour').value;
    var readAmount = document.getElementById('goal').value;
    readPageAmount = readPageAmount.replace(/，/g, ",");
    var amountArr = readPageAmount.split(",");
    if (!readPageAmount.trim()) {
        outMessage("输入每张金额!");
        return false;
    }
    if (!readAmount.trim()) {
        outMessage("输入总金额");
        return false;
    }


    return true;
}

/**
 * 计算
 */
function computeExe() {
    initParm();
    var sourInvoice = document.getElementById('sour').value;
    var targetAmount = document.getElementById('goal').value;
    var data ={};
    data.targetAmount=targetAmount;
    data.sourInvoice=sourInvoice;
    $.ajax({
        url: "../invoiceController/calculateInvoiceNum",
        data: data,
        dataType: "text",
        success: function (data) {
            outMessage(data);
        },
        error:function () {
            outMessage("出错了");
        }
    });
}
/**
 * 数字转大写
 */
function numToUpper() {
    var data ={};
    var amount = $("#amount").val();
    data.queryNum=amount;
    $.ajax({
        url: "../invoiceController/convertNumToUpper",
        data: data,
        dataType: "text",
        success: function (data) {
            $("#amountUpper").text(data);
        }
    });
}

/**
 * 输出内容
 */
function outMessage(obj) {
    document.getElementById('message').innerText = obj;
}
/**
 * 验证输入内容
 * @param obj
 */
function validateAmount(obj) {
    var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
    var bailPayMoney = $(obj).val();//EasyUI textbox 输入框的取值方式
    bailPayMoney = bailPayMoney.trim();
    if (!reg.test(bailPayMoney)){
        var length = bailPayMoney.length;
        $(obj).val(bailPayMoney.substr(0,length-2));
    }
}